﻿using System;
using System.Collections.Generic;
using System.Text;

namespace 设计模式
{
    class gupiao
    {
        public static void main() {
            Fund jijin = new Fund();
            jijin.buy();
            jijin.sell();
            Console.Read();
        }
    }

    //股票1
    class Stock1 {
        public void sell() {
            Console.WriteLine("股票1卖出");
        }

        public void buy() {
            Console.WriteLine("股票1买入");
        }
    }

    class Stock2 {
        public void sell()
        {
            Console.WriteLine("股票2卖出");
        }

        public void buy()
        {
            Console.WriteLine("股票2买入");
        }
    }

    class Stock3
    {
        public void sell()
        {
            Console.WriteLine("股票3卖出");
        }

        public void buy()
        {
            Console.WriteLine("股票3买入");
        }
    }

    class Fund {
        Stock1 gu1;
        Stock2 gu2;
        Stock3 gu3;

        public Fund() {
            gu1 = new Stock1();
            gu2 = new Stock2();
            gu3 = new Stock3();

        }

        public void buy() {
            gu1.buy();
            gu2.buy();
            gu3.buy();
        }

        public void sell() {
            gu1.sell();
            gu2.sell();
            gu3.sell();
        }
    }

}
